﻿namespace Stee.CAP8.MessageBus.Sagas.Core.Sagas.SagaData
{
    public class OrderSagaData : BaseSagaData
    {

        public OrderSagaData(string sagaId) : base(sagaId)
        {

        }



        #region private fileds
        private bool orderCreated;
        private bool orderPaymented;
        private bool orderStockAdjusted;
        #endregion

        /// <summary>
        /// 订单是否创建
        /// </summary>
        public bool OrderCreated
        {
            get => this.orderCreated;
            set
            {
                if (this.orderCreated != value)
                {
                    this.orderCreated = value;
                    this.NotifyPropertyChanged();
                }
            }
        }
        /// <summary>
        /// 支付是否完成
        /// </summary>
        public bool OrderPaymented
        {
            get => this.orderPaymented;

            set
            {

                if (this.orderPaymented != value)
                {
                    this.orderPaymented = value;
                    this.NotifyPropertyChanged();
                }
            }
        }
        /// <summary>
        /// 库存是否调整
        /// </summary>
        public bool OrderStockAdjusted
        {
            get => this.orderStockAdjusted;

            set
            {
                if (this.orderStockAdjusted != value)
                {

                    this.orderStockAdjusted = value;
                    this.NotifyPropertyChanged();
                }
            }
        }
        /// <summary>
        /// saga是否完毕
        /// </summary>
        /// <returns></returns>
        public override bool IsDone()
        {
            this.LoadData();
            return this.OrderCreated && this.OrderPaymented && this.OrderStockAdjusted;
        }
    }
}
